package cn.wolfcode.trip.base.service.impl;


import cn.wolfcode.trip.base.domain.Region;
import cn.wolfcode.trip.base.mapper.RegionMapper;
import cn.wolfcode.trip.base.query.RegionQueryObject;
import cn.wolfcode.trip.base.service.IRegionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.awt.*;
import java.util.List;

@Service
public class RegionServiceImpl implements IRegionService {

    @Autowired
    private RegionMapper regionMapper;


    @Override
    public void saveOrUpdate(Region region) {
        if (region.getId()==null) {
            regionMapper.insert(region);
        }else {
            regionMapper.updateByPrimaryKey(region);
        }
    }

    @Override
    public List<Region> listAll() {
        return regionMapper.selectAll();
    }

    @Override
    public List<Region> queryMenus(RegionQueryObject qo) {
        if (qo.getParentId()==null) {
            return regionMapper.selectMenusParent(qo);
        }
        return regionMapper.selectMenus(qo);
    }

    @Override
    public List<Region> listHotsByState(Integer state) {
        return regionMapper.selectHotsByState(state);
    }
}
